package com.ttbj.location.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import com.ttbj.constant.YingYan;
import com.ttbj.location.service.LocationComponent;

 

@Component
public class LoactionComponentImpl implements LocationComponent {
	private static final Logger logger = LoggerFactory.getLogger(LoactionComponentImpl.class);

	@Override
	public Map<String, String> genRequestMap() {
		Map<String, String> map = new HashMap<String, String>();
		map.put("ak", YingYan.AK);
		map.put("service_id", YingYan.SERVICE_ID);
		return map;
	}


	@Override
	public JSONObject isSuccess(String json) {
		logger.debug("鹰眼接口响应参数:{}", json);
		if(!StringUtils.isEmpty(json)){
			JSONObject jsonObject = new JSONObject(json);
			if(null != jsonObject){
				Integer status = (Integer) jsonObject.get("status");
				if(null != status && status.equals(0)){
					return jsonObject;
				}
			}
		}
		return null;
	}

}
